from typing import Any

from pydantic import BaseModel


class BagInfo(BaseModel):
    room_link: str
    scheme_url: str
    room_id: str
    datatime: str
    bag_rem_time: str
    gold_num: int = 0


class LiveRoom:
    def __init__(self):
        self.room_link: str = ""
        self.scheme_url: str = ""
        self.room_id: str = ""
        self.datatime: str = ""
        self.bag_rem_time: str = ""
        self.gold_num: int = 0
        self.expire_time = ""


# class RegDevice(BaseModel):
#     # def __init__(self):
#     xxx = ""


class WsMsg:
    def __init__(self, cmd: str, req_id: str = "", token: str = "", data: Any = ""):
        self.cmd = cmd
        self.req_id = req_id
        self.token = token
        self.data = data

    @staticmethod
    def error(cmd=None, req_id=None, msg: Any = None):
        return WsMsg(cmd=cmd, req_id=req_id, data=msg)

    @staticmethod
    def ok(msg: Any):
        # return {"cmd": "ok", "data": msg}
        return WsMsg(cmd="ok", data=msg)

    @staticmethod
    def ok_data(data):
        return WsMsg("", "", "", data)


class Result:
    """Http 接口返回"""

    def __init__(self, code, msg, data=None):
        message: str = msg
        code: int = code
        data: Any = data

    @staticmethod
    def ok():
        Result(200, "OK")

    @staticmethod
    def ok_msg(msg):
        return Result(200, msg)

    @staticmethod
    def ok_data(data):
        return Result(200, "OK", data)


class Device():
    def __init__(self, id, ip, box_ip, token, client_id):
        self.id = id
        self.ip = ip
        self.box_ip = box_ip
        self.token = token
        self.client_id = client_id

    def __repr__(self):
        return super().__repr__()

    def __str__(self):
        return super().__str__()
